#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName  :mudidi.py
# @Time      :2023/10/27 
# @Author    :CL
# @email     :1037654919@qq.com


from lvmama import Lvmama
from utils import mongo_manager
def save_mudidi():
    mudidilist = lvmama.get_mudidi()
    # print(mudidilist)
    lvmama_mudidi = mongo_manager('lvmama_mudidi',db = 'lvyou')
    for topic in mudidilist:
        print(topic[0])
        for mudidi in topic[1]:
            name = mudidi[0]
            href = mudidi[1]
            try:
                data  ={'_id':href,'topic':topic,'name':name,'href':href}
                lvmama_mudidi.insertOne(data)
            except  BaseException as e:
                print(e)
if __name__ == '__main__':
    lvmama = Lvmama()
    lvmama_mudidi = mongo_manager('lvmama_mudidi', db='lvyou')
    # save_mudidi()
    # lvmama_mudidi.updateMany({'status':'success'},{'status':None})
    seeds = lvmama_mudidi.findAll()
    for seed in seeds:
        seed['topic'] =seed['topic'][0]

        lvmama_mudidi.updateOne({"_id": seed["_id"]}, seed)
    lvmama_mudidi.close()